using System;

namespace Slaks.Graphs.Algorithms.Wordnet
{
	public class WordnetSynonymGraphDistances
	{
		public static long GetGraphSizeVertexEdgeCount(Graph graph)
		{
			return (graph.GetVertexCount() + graph.GetEdgeCount());
		}

		/// <summary>
		/// MCS
		/// </summary>
		/// <param name="one"></param>
		/// <param name="two"></param>
		/// <returns></returns>
		public static double DistMCS4VertexEdgeCount(Graph one, Graph two)
		{
			double maxCommonSubgraphSize = GetGraphSizeVertexEdgeCount(SynonymMaxCommonSubGraphVertexEdgeCount.GetMCS(one, two));
			double graphSizeOne = GetGraphSizeVertexEdgeCount(one);
			double graphSizeTwo = GetGraphSizeVertexEdgeCount(two);
			if (maxCommonSubgraphSize == 0.0) return 1;
			return 1 - maxCommonSubgraphSize/Math.Max(graphSizeOne, graphSizeTwo);
		}
	}
}